package com.example.system.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author hl
 */
@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer {

    /**
     * bean提前加载
     * @return
     */
    @Bean
    public HandlerInterceptor getTokenInterceptor(){
        return new AuthenticationInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截路径可自行配置多个 可用 ，分隔开
        registry.addInterceptor(getTokenInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/resource/**", "/loginByUserInfo", "/login", "/page/login-1.html","/favicon.ico");
    }
}
